import { queryDictData, queryPerson } from '@/utils/common';
import AdSelect from '@/components/AdSelect';
import AdSearch from '@/components/AdSearch';
import router from 'umi/router';

export const IcCardStatus = [{ code: true, value: '是' }, { code: false, value: '否' }];
export const ICtype=[
  {code: "ORIGINAL", value: "原始舱单", remarks: ""},
  {code: "PREPLAN", value: "预配舱单", remarks: ""}
]

export const codes = {
  select: 'ICCARDPAGE_SELECT',
  add: 'ICCARDPAGE_ADD',
  edit: 'ICCARDPAGE_UPA',
  showDetail: 'ICCARDPAGE_VIEW',
  page: 'ICCARDPAGE',
  getCookie: 'ICCARDPAGE_ADD',
};

export const allUrl = {
  userList: 'tms/tms-bill/selectUserList_s',
  userDetail: 'mds/mds-user/viewDetails',
};

export const routeUrl = {
  add: '/customs/ICCardList/ICCardAdd',
  edit: '/customs/ICCardList/ICCardEdit',
};

export const allDispatchType = {
  list: 'iccard/selectIcCardList', //报关列表
  detail: 'iccard/selectIcCardDetail', //报关详情
  value: 'iccard/allValus',
  save: 'iccard/saveIcCard',
  getRandom: 'iccard/getRandom',
  cookiesRefresh: 'iccard/cookiesRefresh',
};

// export function renderTableAdSelect({ key, data, value, props }) {
//   let params = { onlyRead: true, value };
//   if (key) {
//     const { dictObject } = props;
//     params = { data: dictObject[key], payload: { code: [key] }, ...params };
//   } else {
//     params = { data, ...params };
//   }
//   console.log(' data: dictObject[key]',params.data)

//   params.show = { id: 'value', name: 'code' };
//   return <AdSelect {...params} />;
// }
export function renderTableAdSelect({ key, data, value, props, declare }) {
  let params = { onlyRead: true, value };
  if (key) {
    const { dictObject } = props;
    params = { data: dictObject[key], payload: { code: [key] }, ...params };
  } else {
    params = { data, ...params };
  }
  let show = { id: 'code', name: 'value' };
  if (declare) {
    show = { id: 'value', name: 'code' };
  }
  params.show = show;
  return <AdSelect {...params}/>;
}


export function selectICCardList({ payload = {}, props, call }) {
  const { dispatch, searchValue } = props;
  dispatch({
    type: allDispatchType.list,
    payload,
    callback: data => {
      if (!data) return;
      // queryPerson({ data, props: props, url: allUrl.userList });
    },
  });
}

export function selectDetail({ type, payload, props, callback }) {
  const { dispatch } = props;
  dispatch({
    type,
    payload,
    callback: data => {
      if (!data) return;
      callback && callback(data);
    },
  });
}

export function saveAllValues({ payload = {}, props } = {}) {
  const { dispatch } = props;
  dispatch({
    type: allDispatchType.value,
    payload,
  });
}
